package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * Servlet that sends IE users to the Netscape home page and Netscape (and all
 * other) users to the Microsoft home page.
 */
public class WrongDestination extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String userAgent = request.getHeader("User-Agent");
		System.out.println(userAgent);
		if ((userAgent != null)) {
			if (userAgent.indexOf("MSIE") != -1) {
				response.sendRedirect("http://www.yahoo.com");
			}
			if (userAgent.indexOf("Chrome") != -1) {
				response.sendRedirect("http://www.google.co.in");
			}
		} else {
			response.sendRedirect("http://yahoo.com");
		}
	}
}
